package JHfstools;

import java.awt.EventQueue;

import javax.swing.JDialog;
import javax.swing.JLabel;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import com.jgoodies.forms.factories.FormFactory;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class hftfinder extends JDialog {
	/**
	 * 
	 */
	private static JTextField findword;
	private static JTextField repword;
	private static JButton findnxtbtn;
	private static JButton findprevbtn;
	private static JButton repbtn;
	private static JButton repallbtn;
	private static JButton findallbtn;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					hftfinder dialog = new hftfinder();
					dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
					dialog.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the dialog.
	 */
	public hftfinder() {
		setModal(true);
		setTitle("HFS Tools find");
		setBounds(100, 100, 221, 332);
		getContentPane().setLayout(new FormLayout(new ColumnSpec[] {
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("default:grow"),},
			new RowSpec[] {
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,}));
		
		
		JLabel lblWordToFind = new JLabel("Word to find:");
		getContentPane().add(lblWordToFind, "2, 2");
		
		findword = new JTextField();
		getContentPane().add(findword, "2, 4, fill, default");
		findword.setColumns(10);
		
		findnxtbtn = new JButton("Find Next         ");
		getContentPane().add(findnxtbtn, "2, 6, left, default");
				
		findprevbtn = new JButton("Find Previous ");
		getContentPane().add(findprevbtn, "2, 8, left, default");
		
		JButton exitbtn = new JButton("");
		exitbtn.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				dispose();
			}
		});
		
		findallbtn = new JButton("Find All             ");
		getContentPane().add(findallbtn, "2, 10, left, default");
		
		JLabel lblReplaceWith = new JLabel("Replace with:");
		getContentPane().add(lblReplaceWith, "2, 12");
		
		repword = new JTextField();
		getContentPane().add(repword, "2, 14, fill, default");
		repword.setColumns(10);
		
		repbtn = new JButton("Replace           ");
		repbtn.setToolTipText(" ");
		getContentPane().add(repbtn, "2, 16, left, default");
		
		repallbtn = new JButton("Replace All     ");
		getContentPane().add(repallbtn, "2, 18, left, default");
		exitbtn.setMinimumSize(new Dimension(34, 34));
		exitbtn.setMaximumSize(new Dimension(34, 34));
		exitbtn.setPreferredSize(new Dimension(34, 34));
		exitbtn.setSize(new Dimension(34, 34));
		exitbtn.setIcon(new ImageIcon(hftfinder.class.getResource("images/dlgcan.png")));
		getContentPane().add(exitbtn, "2, 20, center, default");
		
	}

/*	private class findListener implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent e) {
			int i =1;
		}
		
	}*/
	
/*	public static void addfnlistener(ActionListener l){
		System.out.println("In Add Listener");
		getFindnxtbtn().setEnabled(false);
		findnxtbtn.addActionListener(l);
	}*/
	
	public static void addfnlistener(ActionListener l) {
		System.out.println("In Add Listener");
		findnxtbtn.addActionListener(l);
	}
	
	public static JTextField getFindword() {
		return findword;
	}
	public static JButton getFindnxtbtn() {
		return findnxtbtn;
	}
	public static JButton getFindprevbtn() {
		return findprevbtn;
	}
	public static JTextField getRepword() {
		return repword;
	}
	public static JButton getRepbtn() {
		return repbtn;
	}
	public static JButton getRepallbtn() {
		return repallbtn;
	}
	public static JButton getFindallbtn() {
		return findallbtn;
	}
}

